package es.cea.servlets;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class HolaHTML
 */
public class HolaHTML extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public HolaHTML() {
        super();
        // TODO Auto-generated constructor stub
    }

    

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		List<Alumno> alumnos=new ArrayList<Alumno>();
		alumnos.add(new Alumno("juan", 1, 1111111));
		alumnos.add(new Alumno("pepe", 2, 2222222));
		alumnos.add(new Alumno("paco", 3, 3333333));
		
		PrintWriter writer = response.getWriter();
		String mensaje = "" +
				"<html>" +
				"<head>" +
				"</head>" +
				"<body>" +
				"<h1>ALUMNOS!</h1>";
		for(Alumno a:alumnos)
			mensaje+="alumno: "+a.nombre+" " +
					"<a href='./detalleAlumno?id="+a.id+"'>" +
							"ficha alumno" +
							"</a>" +
					"<br>";
		
		mensaje+="" +
				"</body>" +
				"</html>" +
				"";
		writer.print(mensaje);
		writer.close();

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
